var fs = require("fs")
async function isDir(path){
return new Promise((resolve, reject)=>{
    fs.stat(path,(err,stats)=>{
        if (err) {
        return
        }
        if (stats.isDirectory()){
            resolve(true);
        }else {
        resolve(false);
        }
    })
})
}
var path="D:\\测试文件夹"
var dirArr = []
    fs.readdir(path, async (err, data) =>{
        if (err) {
    return
    }
    for (var i= 0; i< data.length; i++){//异步调用isDir 函数，判断是否为文件夹
        if (await isDir(path + '/' + data[i])){
            dirArr.push(data[i])
        }
    }
        console.log(dirArr)
})